
<?php include "fonctions.php"; 
?>

<script language="javascript">

function deleteCollabJs(){
  form = document.forms["formSupp"];  
  if(confirm('Voulez-vous supprimer ce collaborateur ?')){
    form.suppression.value = "supprimer";
    form.submit();
   }   
}

function deleteCompetenceJs(id){
  form = document.forms["formSuppSkill"];  
  if(confirm('Voulez-vous retirer cette compétence à ce collaborateur ?')){
    form.suppression.value = "supprimer";
    form.id_skill.value = id;
    form.submit();
   }   
}

</script>

<table align=center>
  <tr>
    <th style="border:1px solid black">Identifiant du collaborateur</th>
    <th style="border:1px solid black">Nom du collaborateur</th>
    <th style="border:1px solid black">Pr&eacute;nom du collaborateur</th>
     <th style="border:1px solid black">Adresse</th>
    <th style="border:1px solid black">Num&eacute;ro de tel</th>
    <th style="border:1px solid black">Email</th>
    <th style="border:1px solid black">Fonction</th>
  </tr>
    
    
<?php
  
    $collab = getCollabId($_GET['id']);
    echo "<tr><td align=center>".$collab['id']."</td>";
    echo "<td align=center>".$collab['profile']['name']."</td>";
    echo "<td align=center>".$collab['profile']['firstname']."</td>";
    echo "<td align=center>".$collab['profile']['address']."</td>";
    echo "<td align=center>".$collab['profile']['phone']."</td>";
    echo "<td align=center>".$collab['profile']['email']."</td>";
    echo "<td align=center>".$collab['profile']['function']."</td></tr>";
?>
</table>

<br/><p> Voici le d&eacute;tail de ses comp&eacute;tences :</br>

<table align=center>
  <tr>
    <th style="border:1px solid black">Nom de la comp&eacute;tence</th>
    <th style="border:1px solid black">Description de la comp&eacute;tence</th>
    <th style="border:1px solid black">Supprimer cette comp&eacute;tence</th>
  </tr>
  <form name="formSuppSkill" method="post" action="delete_skill.php">
    <input type="hidden" name="suppression" value="" />
    <input type="hidden" name="id_skill" value="" />
    <input type="hidden" name="id_coll" value="<?php echo $collab['id'];?>" />
<?php

  $skills = $collab['skills'];
  foreach ($skills as $skill) {
    $skill_detail = getSkillId($skill);

    echo "<td align=center>".$skill_detail['name']."</td>";
    echo "<td align=center>".$skill_detail['description']."</td>";
    echo '<td align=center><input type="button" onclick="javascript:deleteCompetenceJs('.$skill_detail['id'].');" value="Supprimer cette comp&eacute;tence"/></td></tr>';
  }
?>
</form>
</table>
</p>


<input type="button" value="Modifier ce collaborateur" onclick="javascript:window.location='<?php echo 'modify_collab.php?id='.$collab['id']; ?>'"/>
<form name="formSupp" method="post" action="delete_collaborator.php">
  <input type="hidden" name="suppression" value="" />
  <input type="hidden" name="id_supp" value="<?php echo $collab['id']; ?>" />
</form>



<p><input type="button" onclick="javascript:deleteCollabJs();" value="Supprimer ce collaborateur"/></p>
